package com.gujia.rabbitmq.routing;

import com.gujia.rabbitmq.util.ConnectionUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.util.Random;

public class Sender {

    private static final String EXCHANGE_NAME="test_exchange_direct";
    public static void main(String[] args) throws Exception{
        Connection connection = ConnectionUtils.getConnction();
        Channel channel = connection.createChannel();

        channel.exchangeDeclare(EXCHANGE_NAME,"direct");

        String msg="hello direct"+ new Random().nextInt();

        String routingKey = "error";

        channel.basicPublish(EXCHANGE_NAME,routingKey,null,msg.getBytes());

        channel.close();
        connection.close();
    }
}
